package com.hunan.api.catv.action.interactive;

import com.hunan.api.catv.action.BaseAction;
import com.hunan.api.catv.common.Api;
import com.hunan.api.catv.entity.Result;
import com.hunan.api.catv.service.biz.interactive.InteractiveBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.security.NoSuchAlgorithmException;

/**
 * @Author: wangchao
 * @Date: 2021/2/1 14:06
 */
@RestController
@RequestMapping(Api.interactive)
@Validated
public class InteractiveAction extends BaseAction {

    @Autowired
    InteractiveBiz interactiveBiz;


    /**
     * 完成任务新增白金岛金币
     */
    @PostMapping("/addGoldToByPlatinumIslandTask")
    public Result addGoldToByPlatinumIslandTask(Integer type, Integer memberId) throws NoSuchAlgorithmException {
        return buildOK(interactiveBiz.addGoldToByPlatinumIslandTask(type, memberId), "");
    }

    /**
     * 获取排行榜已经用户战绩
     */
    @GetMapping("/getRanklist/{limit}")
    public Result getRanklist(@PathVariable("limit") Integer limit, HttpServletRequest request) throws NoSuchAlgorithmException {
        return buildOK(interactiveBiz.getRanklist(limit, getMemberIdV2(request)), "");
    }
}
